package com.debao;

import com.debao.common.core.domain.AjaxResult;
import com.debao.common.utils.SecurityUtils;
import com.debao.system.domain.Feedback;
import com.debao.system.service.IFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/api/feedback")
@RestController
@CrossOrigin
public class ApiFeedback {

    @Autowired
    private IFeedbackService feedbackService;

    @PostMapping("/add")
    public AjaxResult add(@RequestBody Feedback feedback) {
        feedback.setUserId(SecurityUtils.getUserId());
        int row = feedbackService.insertFeedback(feedback);
        if (row == 1) {
           return AjaxResult.success("提交成功");
        }
        if (row == 0) {
            return AjaxResult.error("您本月已提交过意见反馈");
        }
        return AjaxResult.error("提交失败");
    }

}
